package com.alone.test;

import com.alone.jpa.entity.enhancer.AutoFillDefaultValueProvider;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

/**
 * @author Alone
 */
@Component
public class AutoFillValue implements AutoFillDefaultValueProvider {

    private static final Map<String, Supplier<Object>> MAP = new HashMap<>();

    static {
        MAP.put("createTime", LocalDateTime::now);
        MAP.put("updateTime", LocalDateTime::now);
        MAP.put("deleted", () -> false);

        MAP.put("deptId", () -> 1L);
    }

    @Override
    public Map<String, Supplier<Object>> getValueMap() {
        return MAP;
    }
}
